package com.wlyuan.index.domain.index;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * @author yuanjie
 */
@Data
@Accessors(chain = true)
@Document(indexName = "full_order_index")
@EqualsAndHashCode(exclude = {"indexAt", "delayedDays"})
public class OrderIndex {
    @Id
    private Long id;

    @ApiModelProperty("订单ID")
    private Long orderId;

    @ApiModelProperty("单据编号")
    @Field(type = FieldType.Keyword)
    private String orderNo;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("合同编号")
    private String contractNo;

    @ApiModelProperty("总数量")
    private Integer totalQuantity;

    @ApiModelProperty("总重量")
    private BigDecimal totalWeight;

    @ApiModelProperty("总体积")
    private BigDecimal totalVolume;

    @ApiModelProperty("总价值")
    private BigDecimal totalValue;

    @ApiModelProperty("计算后的重量")
    private BigDecimal calculateWeight;

    @ApiModelProperty("计算后的总体积")
    private BigDecimal calculateVolume;

    @ApiModelProperty("计算后的总价值")
    private BigDecimal calculateValue;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty("发货时间")
    private LocalDateTime fromTime;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty("收货时间")
    private LocalDateTime toTime;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货方名称")
    private String customerName;

    @ApiModelProperty("发货方ID")
    private Long customerId;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货方名称")
    private String consigneeName;

    @ApiModelProperty("收货方ID")
    private Long consigneeId;

    @ApiModelProperty("承运方ID")
    private Long carrierId;

    @ApiModelProperty("运输模式")
    private Integer transportMode;

    @ApiModelProperty(value = "市内/长途")
    private Integer distanceType;

    @ApiModelProperty("是否送货")
    private Boolean deliver;

    @ApiModelProperty("是否装货")
    private Boolean load;

    @ApiModelProperty("是否提货")
    private Boolean pick;

    @ApiModelProperty("是否卸货")
    private Boolean unload;

    @ApiModelProperty("是否保价")
    private Boolean insure;

    @ApiModelProperty("跟踪类型")
    private Integer trackType;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("跟踪编号")
    private String trackNo;

    @ApiModelProperty("是否绑定设备")
    private Boolean hasDevice;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货省份")
    private String fromProvince;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货省份编码")
    private String fromProvinceCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货城市")
    private String fromCity;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货城市编码")
    private String fromCityCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货区域")
    private String fromDistrict;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货区域编码")
    private String fromDistrictCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货详细地址")
    private String fromAddress;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("发货联系人")
    private String fromContactName;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货联系人手机")
    private String fromContactMobile;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货省份")
    private String toProvince;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货省份编码")
    private String toProvinceCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货城市")
    private String toCity;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货城市编码")
    private String toCityCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货区域")
    private String toDistrict;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货区域编码")
    private String toDistrictCode;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货详细地址")
    private String toAddress;

    @Field(type = FieldType.Keyword)
    @ApiModelProperty("收货联系人")
    private String toContactName;

    @ApiModelProperty("收货人电话号码")
    @Field(type = FieldType.Keyword)
    private String toContactMobile;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("订单状态")
    private Integer status;

    @Field(type = FieldType.Integer)
    @ApiModelProperty("异常")
    private Set<Integer> exceptions;

    @ApiModelProperty("是否延期")
    private Boolean delayed;

    @ApiModelProperty("延时天数")
    private Integer delayedDays;

    @ApiModelProperty("逾期未签收")
    private Boolean overdueNoSign;

    @ApiModelProperty("到达计划")
    private Integer arrivalPlan;

    @ApiModelProperty("是否生成场景证书")
    private Boolean hasCert;

    @ApiModelProperty("是否开通场景证书")
    private Boolean generateCert;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty("签收时间")
    private LocalDateTime signTime;

    @ApiModelProperty("签收类型")
    private Integer signType;

    @ApiModelProperty("是否已签收")
    private Boolean signed;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty("回单时间")
    private LocalDateTime receiptTime;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createAt;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    @ApiModelProperty(value = "最后警报时间")
    private LocalDateTime lastWarnAt;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    private LocalDateTime indexAt;

    @ApiModelProperty(value = "源订单ID")
    @Field(type = FieldType.Keyword)
    private String sourceId;

    // JIA JIA: XD SD
    @Field(type = FieldType.Keyword)
    @ApiModelProperty("业务单号")
    private Set<String> businessNos;

    @ApiModelProperty("租户ID")
    @Field(type = FieldType.Long)
    private Long tenantId;

    @Field(type = FieldType.Long)
    private Long version;
}